import {ADD_COUNTS, ADD_TO_CART, CHANGE_SELECT} from './mutations-types';
export default {
  /* 
    mutations的唯一目的就是改变state中的状态
    mutations中的函数做的事情要尽可能的单一
    所以判断，或者异步的操作都要放到actions中去
  */
  [ADD_COUNTS](state, payLoad){
    payLoad.count += 1;
  },
  [ADD_TO_CART](state, payLoad){
    payLoad.count = 1;
    payLoad.isSelect = true;
    state.cartList.push(payLoad);
  },
  [CHANGE_SELECT](state, payLoad){
    payLoad.isSelect = !payLoad.isSelect;
  }
}